/*
*	Copyright (C) 2014  Julio Montes, Mario Carrillo
*	
*	Julio Montes e-mail: imc.coder@gmail.com 
*
*	Mario Carrillo e-mail: mario_90ago@live.com.mx
*
*	BSD 3-Clause License
*/

#ifndef ALLIANCE_TOOLPANEL_H
#define ALLIANCE_TOOLPANEL_H

#include <wx/wx.h>
#include <wx/notebook.h>
#include <map>

#include "sdk/include/filecfg.h"
#include "alliance/include/tool.h"

namespace alliance
{
    class EnvarPanel;
    class ToolCtrl;

    class ToolPanel : public wxPanel
    {
    public:
        static const wxString s_fileExtensionTool;

        ToolPanel( wxWindow *parent, wxWindowID id );

        virtual ~ToolPanel();

        bool LoadFile( const wxString &filename );

        bool LoadTool( const Tool &tool );

        const wxString &GetCommand() const{ return m_command; }

        void SetValue( const wxString &key, const wxString &text );

        void SetValue( const wxString &key, bool value );

        void AddVariable( const wxString &name, const wxString &value );

        void AddFilesToArray( wxArrayString *arrayFiles ) const;

        Tool GetTool() const;

        bool IsOk() const;

        /**
        * @brief checks if the tab can be changed
        *
        * @return true if can be changed, false otherwise
        */
        bool OnPageChanging() const;

        /**
        * @brief
        */
        bool OnPageChanged( const wxArrayString &arrayFiles ) const;
    protected:
    private:
        wxString m_command;
        wxString m_commandFormat;
        wxBoxSizer *m_boxSizer;
        EnvarPanel *m_envarPanel;
        std::map<wxString,ToolCtrl *> m_controls;

        bool LoadArguments( const sdk::vectorElementsString &vectorElements );
        bool LoadOptions( const sdk::vectorElementsString &vectorElements );
        void UpdateOptionsDependents();
    };
}
#endif//ALLIANCE_TOOLPANEL_H
